package com.hup.minicontroller.client.view.connected;

import com.hup.minicontroller.common.constant.NetConstant;
import com.hup.utils.commons.start.LookThemeUtil;
import com.hup.utils.swing.customView.ImageButton;

import javax.swing.*;
import java.awt.*;

/**
 * @author hugan
 * @date 2021/5/24
 */
public class ConnectedForm {
    public JPanel root;
    public ScreenView screenView;
    public ControlConfigPanel controlConfigPanel;
    public ImageButton btnTrigger;
    public ImageButton btnBack;
    public ImageButton btnHome;
    public ImageButton btnApp;
    public JLabel txtDisableControl;
    public TouchPadView touchPadView;

    public ConnectedForm() {
        $$$setupUI$$$();
        controlConfigPanel.setPreferredSize(new Dimension(450, 150));
        LookThemeUtil.fixScale(controlConfigPanel);
        controlConfigPanel.sbFps.setValuesStr(parse(NetConstant.FPS));
        controlConfigPanel.sbScreenSize.setValuesStr(parse(NetConstant.SCREEN_SIZE));
        controlConfigPanel.sbScreenQuality.setValuesStr(parse(NetConstant.SCREEN_QUALITY));
        //ComponentUtil.setBackground((JComponent) btnTrigger.getParent(), Color.WHITE.darker());
    }

    private String parse(int[] array) {
        StringBuilder sb = new StringBuilder();
        for (int val : array) {
            sb.append(val).append(',');
        }
        sb.deleteCharAt(sb.length() - 1);
        return sb.toString();
    }

    /**
     * Method generated by IntelliJ IDEA GUI Designer
     * >>> IMPORTANT!! <<<
     * DO NOT edit this method OR call it in your code!
     *
     * @noinspection ALL
     */
    private void $$$setupUI$$$() {
        root = new JPanel();
        root.setLayout(new GridBagLayout());
        screenView = new ScreenView();
        GridBagConstraints gbc;
        gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = 1;
        gbc.weightx = 1.0;
        gbc.weighty = 1.0;
        gbc.fill = GridBagConstraints.BOTH;
        root.add(screenView, gbc);
        controlConfigPanel = new ControlConfigPanel();
        gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = 2;
        root.add(controlConfigPanel.$$$getRootComponent$$$(), gbc);
        final JPanel panel1 = new JPanel();
        panel1.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));
        gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = 3;
        gbc.fill = GridBagConstraints.BOTH;
        root.add(panel1, gbc);
        btnTrigger = new ImageButton();
        btnTrigger.setIcon(new ImageIcon(getClass().getResource("/img/connected/button_floater_trigger.png")));
        panel1.add(btnTrigger);
        btnBack = new ImageButton();
        btnBack.setIcon(new ImageIcon(getClass().getResource("/img/connected/button_floater_back.png")));
        panel1.add(btnBack);
        btnHome = new ImageButton();
        btnHome.setIcon(new ImageIcon(getClass().getResource("/img/connected/button_floater_home.png")));
        panel1.add(btnHome);
        btnApp = new ImageButton();
        btnApp.setIcon(new ImageIcon(getClass().getResource("/img/connected/button_floater_app.png")));
        panel1.add(btnApp);
        txtDisableControl = new JLabel();
        txtDisableControl.setText("禁控模式");
        panel1.add(txtDisableControl);
        touchPadView = new TouchPadView();
        gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = 0;
        gbc.weightx = 1.0;
        gbc.weighty = 1.0;
        gbc.fill = GridBagConstraints.BOTH;
        root.add(touchPadView, gbc);
    }

    /**
     * @noinspection ALL
     */
    public JComponent $$$getRootComponent$$$() { return root; }

}
